<extend name="Base/common"/>
<block name="body">
    <div id="BeTeature" style="margin-bottom:100px;">
        <header>
            <a href="__MODULE__/Index/index" class="back"><img src="__IMG__/images/back_03.png"/></a><?php echo $intro;?>
            <neq name="pause" value="1">
            <eq name="Think.get.teaching" value="2">
            <a href="javascript:;" class="sure"><eq name="end_teach" value="1">信息上架<else/>信息下架</eq></a>
            <else/>
            <a href="javascript:;" class="sure"><eq name="end_study" value="1">信息上架<else/>信息下架</eq></a>
            </eq>
            </neq>
        </header>
        <style>
		.pianos1{
			width:750px;
			max-height: 90px;
		    padding: 5px 20px;
			font-size: 28px;
			line-height: 40px;
			overflow:hidden;
			word-break: break-all;
		}
        </style>
        <form action="__SELF__"  class="form-horizontal"  method="post" enctype="multipart/form-data" id="mac">
            <div class="BeTeature">
                <ul>
                    <li>
                        <h1><img src="__IMG__/images/headLine_07.jpg"/><?php if($_GET['teaching'] == 2){?>教学内容<?php }else{?>学习内容<?php }?><a href="__CONTROLLER__/addCourse/teaching/{$Think.get.teaching}"><img src="__IMG__/images/book_03.jpg" class="f-fr"/></a></h1>
                    <div class="LearnAbout">
			<ul>
				<volist name="courses" id="c">
				<li>
					<h2>
						<span class="f-fl">{$c.title}</span>
						<!-- lkl新增显示状态S -->
						<if condition="$c['passed'] eq 0">
						<span class="f-fl" style="margin-left:30px;margin-left: 30px; font-size: 20px;padding: 4px 6px;background: #fea620;color: #fff;">
						审核中</if>
						<if condition="$c['passed'] eq 1">
						<span class="f-fl" style="margin-left:30px;margin-left: 30px; font-size: 20px;padding: 4px 6px;background: #3dbb7e;color: #fff;">
						已通过</if>
						<if condition="$c['passed'] eq 2">
						<span class="f-fl" style="margin-left:30px;margin-left: 30px; font-size: 20px;padding: 4px 6px;background: #f85f3f;color: #fff;">
						未通过</if>
						</span>
						<!-- lkl新增显示状态E -->
						<span class="f-fr">{$c.salary}元/小时</span>
					</h2>
					<div>{$c.content}</div>
					<p>
						<span class="moren">删除</span>
						<input type="hidden" value="{$c.id}">
						<a href="__CONTROLLER__/addCourse/teaching/{$Think.get.teaching}/id/{$c.id}"><span>修改</span></a>
					</p>
					<div class="clear"></div>
				</li>
				</volist>
			</ul>
			<script type="text/javascript">
			$('.moren').on('click',function(){
				var id = $(this).next().val();
                layer.open({
                    content: '您确定要删除吗？'
                    ,btn: ['确定', '取消']
                    ,yes: function(index){
                    	$.ajax({
                    		url: "{:U('delCourse')}",
                    		type: 'POST',
                    		dataType: 'json',
                    		data: {id: id},
                    		success:function(data){
                    			layer.msg(data,{time:1500},function(){
                    				location.reload();
                    			});
                    		}
                    	});
                    }
                  });
			});
		</script>
		</div>
                    </li>
                    <li style="display:none;">
                        <h1><img src="__IMG__/images/headLine_07.jpg"/>一句话简介 <a href="javascript:;" class="inaword"><img src="__IMG__/images/book_03.jpg" class="f-fr"/></a></h1>
                        <p class="piano1">{$introduce.inaword}</p>
                        <div class="area" style="display: none;"><textarea name="inaword" class="inaword">{$introduce.inaword}</textarea></div>
                    </li>
					<?php if($_GET['teaching'] == 2){?><li><?php }else{?><li style="display:none;"><?php }?>
                        <h1><img src="__IMG__/images/headLine_07.jpg"/>简介
						<a href="javascript:;" class="introduce"><img src="__IMG__/images/book_03.jpg" class="f-fr"/></a></h1>
                        <p class="piano1">{$introduce.introduce}</p>
                        <div class="area" style="display: none;"><textarea name="introduce" class="introduce" id="intr" onKeyDown="checkMaxInput(this)" onKeyUp="checkMaxInput(this)" >{$introduce.introduce}</textarea>
						<font align="right" id=remLen>140</font>字
						</div>
                    </li>
                    <if condition="$_GET['teaching'] eq 2">
                    <li>
                        <h1><img src="__IMG__/images/headLine_07.jpg"/>微信二维码 </h1>
                        <p class="piano1"></p>
                        <div class="area">
                            <img id="pic"  src="<if condition="$pics neq ''">__ROOT__{$pics|getimg=###}<else/>__IMG__/images/scewm_03.jpg</if>" alt="点击上传图片">
                            <!--<img id="pic" src="__IMG__/images/scewm_03.jpg" alt="点击上传图片">-->
                            <input id="upload" name="logo" accept="image/*" type="file" style="display: none"/>
                        </div>
                    </li>
                    </if>
                    <li>
                        <h1><img src="__IMG__/images/headLine_07.jpg"/>地区 <a href="javascript:;" class="introduce"><img src="__IMG__/images/book_03.jpg" class="f-fr"/></a></h1>
                        <p class="piano1">{$data.area_id|getParentArea=###}{$data.area_id|getArea=###}</p>
                        <div class="area areas" style="display: none;">
                            <select name="pid" id="aaaa">
                                <empty name="sheng">
                                    <option value="">请选择</option>
                                    <else/>
                                <option value="" class="aaaa">{$sheng.title}</option>
                                </empty>
                                <volist name="areas" id="v">
                                    <option value="{$v.id}">{$v.title}</option>
                                </volist>
                            </select>
                            <select name="area_id" class="class-area_id" id="aa">
                                <empty name="data.area_id" value="0">
                                    <option value="">请选择</option>
                                    <else/>
                                    <volist name="towArea" id="vol">
                                        <option value="{$vol.id}"<if condition="$vol['id'] eq $data['area_id']"> selected="selected"</if>>{$vol.title}</option>
                                    </volist>
                                </empty>
                            </select>
                        </div>
                    </li>
                </ul>
				<eq name="Think.get.teaching" value="2">
				<p style="margin-top:30px;color:orange;text-align:center;">上传正确的微信二维码，这样别人才可以联系到你。</p></eq>
                <p style="text-align: center;font-size: 24px;display:inline-block;padding-left:20px;"></p>
                <input type="hidden" name="id" value="{$introduce.id}">
                <input type="submit" id="btn" style="margin-top:0px;" class="ajax-file " target-form="form-horizontal" value="提交" />
            </div>
        </form>
        <div class="stop"></div>
    </div>
    <style>
        .area{text-align: center;}
        .area .inaword{width: 40rem;height: 15rem;border-radius: 0.5rem;padding: 0.5rem;}
        .area .introduce{width: 40rem;height: 20rem;border-radius: 0.5rem;padding: 0.5rem;}
        #pic{width: 250px;margin: 20px auto;cursor: pointer;height: 250px;border: 1px solid; }
        #upload{border: none; }
      .areas{padding:10px 0;}
    </style>
	<script type="text/javascript">
			maxLen = 140;	//可以输入的最多字数
			function checkMaxInput(obj) {
				if (obj.value.length > maxLen){	//如超过了限制
					obj.value = obj.value.substring(0, maxLen);	//就去掉多余的字
					document.getElementById('remLen').innerText = '0';
					layer.alert("字数超过限制");
				}else{
					document.getElementById('remLen').innerText = maxLen - obj.value.length;//计算并显示剩余字数
				}
			}
			function va_length(){
				var text = document.getElementById("intr");
				document.getElementById('remLen').innerText = maxLen - text.value.length;
			}
			va_length();
		</script>
    <script type="text/javascript">
        $('#aaaa').click(function(){
        });
        //地区联动
        $('select[name=pid]').change(function () {
            $('.aaaa').remove();
//            $('select[name=area_id] option').remove();
            var id = $(this).val();
            $.post('__MODULE__/Area/areaList', {'id': id}, function (res) {
                $('.class-area_id').find('option').remove();
				
                $.each(res, function (index, el) {
				
                    $('#aa').append('<option value=\'' + el.id + '\'>' + el.title + '</option>');

                });

				


            });
        });
        //修改地区的
        $('.class-area_id').change(function () {
           var creaname = $('#aaaa').find('option:selected').html();
           var val = $(this).find('option:selected').html();
            $(this).parent().prev().replaceWith("<p class='piano1'>" + creaname+val + "</p>");
			$(".areas").css("display","none");
        });
        $(function () {
            $("#pic").click(function () {
                $("#upload").click();               //隐藏了input:file样式后，点击头像就可以本地上传
                $("#upload").on("change", function () {
                    var objUrl = getObjectURL(this.files[0]);  //获取图片的路径，该路径不是图片在本地的路径
                    if (objUrl) {
                        $("#pic").attr("src", objUrl);      //将图片路径存入src中，显示出图片
                    }
                });
            });
        });
        $(function () {
            var url = window.location.href;
            var msg = url.indexOf('msg', -1);
            if (msg != -1) {
                var data = "{$_GET['msg']}";
                data = data.substring(0, data.length - 1);
                data = data.substr(1, data.length);
                if (data != '') {
                    layer.alert(data);
                }
            }
        });
        //建立一個可存取到該file的url
        function getObjectURL(file) {
            var url = null;
            if (window.createObjectURL != undefined) { // basic
                url = window.createObjectURL(file);
            } else if (window.URL != undefined) { // mozilla(firefox)
                url = window.URL.createObjectURL(file);
            } else if (window.webkitURL != undefined) { // webkit or chrome
                url = window.webkitURL.createObjectURL(file);
            }
            return url;
        }
        $('.ajax-file').click(function () {
          //hjl 检查图片地址
          var pic_src = $('#pic').attr('src');
           //alert(pic_src.indexOf("scewm_03"));
          if(pic_src.indexOf("scewm_03") > -1 || pic_src==''){
            alert('您未上传微信二维码');
            return false;
          }
            var url = $('#mac').attr('action');
            var fd = new FormData($("#mac")[0]);
            $.ajax({
                url: url,
                type: "POST",
                data: fd,
                processData: false, // 告诉jQuery不要去处理发送的数据
                contentType: false, // 告诉jQuery不要去设置Content-Type请求
            });
        })
    </script>
    <script>
        //切换一句话介绍输入框
        $('.inaword').click(function () {
            tog($(this));
        });
        //切换自我介绍输入框
        $('.introduce').click(function () {
            tog($(this));
        });
        function tog(obj) {
            if (obj.parent().next('p').is(':hidden')) {
                obj.parent().next('p').show(200).next('div').slideUp(200);
                //修改显示的数据
                obj.parent().next('p').html(obj.parent().nextAll('div').find('textarea').val());
            } else {
                obj.parent().next('p').hide(200).next('div').slideDown(200).find('textarea').focus();
            }
        }
        //授课、学习状态切换
        $('.sure').click(function () {
            var val = $(this).html();
            var text;
            switch (val) {
                case '开始学习':
                case '信息上架':
                    text = '您是否要' + val + '，开始后您将重新在列表中展示。'
                    break;
                case '停止学习':
                case '信息下架':
                    text = '您是否要' + val + '，停止后您将不在列表中展示。'
                    break;
            }
            console.log(text);
            var teach = '{$Think.get.teaching}';
            if (teach == '1') {
                var column = 'end_study';
            } else if (teach == '2') {
                var column = 'end_teach';
            }
            layer.confirm(text, function (index) {
                $.post('__MODULE__/UserMember/endcourse', {column: column}, function (data) {
                    layer.close(index);
                    layer.msg(data, {time: 1500}, function () {
                        location.reload();
                    });
                });
            });
        });
    </script>
<script type="text/javascript">
        $(function () {
            //聚焦导航搜索 最底部消失
            $('#search').focus(function () {
                $('.LinkB').hide();
                $('.Fix').hide();
            });
            $('#search').blur(function () {
                $('.LinkB').show();
                $('.Fix').show();
            });
        })
        $('.jia').click(function () {
            $('.list1').hide();
            $('.jia').css('background', '#f6ce78');
            $('li[name=pid]').css('background', '#FFF');
            $('.sure').click(function () {
                users('0', '0', '0', '0', '0', '', '', '', '', '', '-1');
            });
        });
        $('li[name=pid]').click(function () {
            var v = $(this).attr('area_pid');
            var a = $(this).attr('data-title');
            $('.list1').show();
            $('.dangqian').html("当前:" + a);
            $('li[name=pid]').css('background', '#FFF');
            $(this).css('background', '#f6ce78');
            $('.jia').css('background', '#FFF');
            $.ajax({
                url: '{:U('area / areaList')}',
                type: 'POST',
                dataType: 'json',
                data: {id: v},
                success: function (data) {
                    var content = "<li class='' area_id=''>全城</li>";
                    $.each(data, function (name, value) {
                        content += "<li area_id='" + value.id + "'>" + value.title + "</li>"
                    });
                    content += "<div class='clear'></div>";
                    $('#area_list').html("");
                    $('#area_list').append(content);
                }
            })
        });
        $('li[name=pid]').click(function () {
            $(document).scrollTop(0);
            var va = $(this).attr('area_pid');
            $('#area_list').on('click', 'li', function () {
                var vs = $(this).attr('area_id');
                $('#area_list').find('li').removeClass('moren');
                $(this).addClass('moren');
                $('.sure').click(function () {
                    users('0', '0', '0', '0', '0', va, vs, '', '', '', '-1');
                });
            });
            $('.sure').click(function () {
                users('0', '0', '0', '0', '0', va, '', '', '', '', '-1');
            });
        });
        function qq_position()
        {
            console.log('开始定位！');
            var geolocation = new qq.maps.Geolocation("OB4BZ-D4W3U-B7VVO-4PJWW-6TKDJ-WPB77", "myapp");
            if(geolocation){
                    var options = {timeout: 8000};
                    geolocation.getLocation(showPosition, showErr, options);
                    console.log('尝试加载定位');
            }else{
                    alert("定位尚未加载");
            }
        }
        function showErr(err)
        {
            //alert("定位出现错误");
        }
        function SetCookie(name,value)
        {
            var Days = 30;
            var exp = new Date();
            exp.setTime(exp.getTime() + 60*1000);
            document.cookie = name + "=" + escape (value) +  ";expires=" + exp.toGMTString();
        }
        /*获取Cookie*/
        function getCookie(cookie_name)
        {
            var allcookies = document.cookie;
            var cookie_pos = allcookies.indexOf(cookie_name);   //索引的长度
            // 如果找到了索引，就代表cookie存在，
            // 反之，就说明不存在。
            if (cookie_pos != -1)
            {
                // 把cookie_pos放在值的开始，只要给值加1即可。
                cookie_pos += cookie_name.length + 1;      //这里容易出问题，所以请大家参考的时候自己好好研究一下
                var cookie_end = allcookies.indexOf(";", cookie_pos);
                if (cookie_end == -1)
                {
                    cookie_end = allcookies.length;
                }
                var value = unescape(allcookies.substring(cookie_pos, cookie_end));         //这里就可以得到你想要的cookie的值了。。。
            }
            return value;
        }
        function showPosition(positions)
        {
            var lat = positions.lat;
            var lng = positions.lng;
            var city = encodeURI(positions.city);
            var province = encodeURI(positions.province);
            var district = encodeURI(positions.district);
            SetCookie('lat',lat);
            SetCookie('lng',lng);
            SetCookie('province',province);
            SetCookie('city',city);
            SetCookie('district',district);
            console.log('定位成功！！');
            //window.location.reload();
        }
        window.onload = function() {
         /*页面加载完成后执行*/
         var lat = getCookie('lat');
         if (!lat) {
                qq_position();
            }
        };
    </script>
</block>